package p234

import node.ListNode
import java.util.*


class StackFullStragty : Stragty {
    override fun isPalindrome(head: ListNode?): Boolean {
        var tempt: ListNode? = head
        var root: ListNode? = head

        val stack: Stack<ListNode> = Stack()

        while (tempt != null) {
            stack.push(tempt)
            tempt = tempt.next
        }

        while (!stack.empty() && root != null) {
            var t: ListNode = stack.pop()
            if (t.`val` != root.`val`) {
                return false
            }
            root = root.next
        }

        return true
    }
}